package com.wz.project.sap.MATUNIT.controller;

import java.util.List;

import com.wz.project.sap.MATUNIT.domain.ZflWmsGetMatUnit;
import com.wz.project.sap.MATUNIT.service.IZflWmsGetMatUnitService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 物料单位转换Controller
 * 
 * @author wz
 * @date 2022-09-14
 */
@Controller
@RequestMapping("/MATUNIT/MATUNIT")
public class ZflWmsGetMatUnitController extends BaseController
{
    private String prefix = "MATUNIT/MATUNIT";

    @Autowired
    private IZflWmsGetMatUnitService zflWmsGetMatUnitService;

    @RequiresPermissions("MATUNIT:MATUNIT:view")
    @GetMapping()
    public String MATUNIT()
    {
        return prefix + "/MATUNIT";
    }

    /**
     * 查询物料单位转换列表
     */
//    @RequiresPermissions("MATUNIT:MATUNIT:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZflWmsGetMatUnit zflWmsGetMatUnit)
    {
        startPage();
        List<ZflWmsGetMatUnit> list = zflWmsGetMatUnitService.selectZflWmsGetMatUnitList(zflWmsGetMatUnit);
        return getDataTable(list);
    }

    /**
     * 导出物料单位转换列表
     */
    @RequiresPermissions("MATUNIT:MATUNIT:export")
    @Log(title = "物料单位转换", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZflWmsGetMatUnit zflWmsGetMatUnit)
    {
        List<ZflWmsGetMatUnit> list = zflWmsGetMatUnitService.selectZflWmsGetMatUnitList(zflWmsGetMatUnit);
        ExcelUtil<ZflWmsGetMatUnit> util = new ExcelUtil<ZflWmsGetMatUnit>(ZflWmsGetMatUnit.class);
        return util.exportExcel(list, "MATUNIT");
    }

    /**
     * 新增物料单位转换
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存物料单位转换
     */
    @RequiresPermissions("MATUNIT:MATUNIT:add")
    @Log(title = "物料单位转换", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZflWmsGetMatUnit zflWmsGetMatUnit)
    {
        return toAjax(zflWmsGetMatUnitService.insertZflWmsGetMatUnit(zflWmsGetMatUnit));
    }

    /**
     * 修改物料单位转换
     */
    @GetMapping("/edit/{MATNR}")
    public String edit(@PathVariable("MATNR") String MATNR, ModelMap mmap)
    {
        ZflWmsGetMatUnit zflWmsGetMatUnit = zflWmsGetMatUnitService.selectZflWmsGetMatUnitById(MATNR);
        mmap.put("zflWmsGetMatUnit", zflWmsGetMatUnit);
        return prefix + "/edit";
    }

    /**
     * 修改保存物料单位转换
     */
    @RequiresPermissions("MATUNIT:MATUNIT:edit")
    @Log(title = "物料单位转换", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZflWmsGetMatUnit zflWmsGetMatUnit)
    {
        return toAjax(zflWmsGetMatUnitService.updateZflWmsGetMatUnit(zflWmsGetMatUnit));
    }

    /**
     * 删除物料单位转换
     */
    @RequiresPermissions("MATUNIT:MATUNIT:remove")
    @Log(title = "物料单位转换", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zflWmsGetMatUnitService.deleteZflWmsGetMatUnitByIds(ids));
    }
}
